package check;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*;

public class BoxRenderer extends DefaultTableCellRenderer {

    private Font font;

    public BoxRenderer() {
        // 在构造函数中设置字体
        this.font = new Font("SimSun", Font.PLAIN, 14);
    }

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value,
                                                   boolean isSelected, boolean hasFocus, int row, int column) {
        super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

        // 设置字体
        setFont(font);

        // 设置文本水平和垂直居中
        setHorizontalAlignment(SwingConstants.CENTER);
        setVerticalAlignment(SwingConstants.CENTER);

        return this;
    }
}
